package com.geeklan.base.animate;

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;

public class ViewAnimate {
    /***
     * view平移动画
     * @param view
     * @param x
     * @param width
     * @param count
     */
    public static void moveViewToTargetView(View view, int x, int width, int count) {
        if(count <= 0) return;
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.width = width / count;
        view.setLayoutParams(layoutParams);
        view.animate()
                .translationX(x)
                .setDuration(200)
                .setInterpolator(new DecelerateInterpolator())
                .withLayer()
                .start();
    }
}
